<?php
include_once('class/autoload.php');
session_start();
$site = new page_base_securisee('inscriptionE');
$site->titre = "Inscription des eleves";

$site->corps = "

	Sur cette page, vous pouvez inscrire vos eleves pour le CROSS USEP :

<head>
	<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
	<title>jQuery Form Validation</title>
	<link rel='stylesheet' href='styles/css/validationEngine.jquery.css' type='text/css' media='screen' title='no title' charset='utf-8'>
	<link rel='stylesheet' href='styles/css/template.css' type='text/css' media='screen' title='no title' charset='utf-8'>
	<script src='styles/js/jquery.js' type='text/javascript'></script>
	<script src='styles/js/jquery.validationEngine-fr.js' type='text/javascript'></script>
	<script src='styles/js/jquery.validationEngine.js' type='text/javascript'></script>
	
	</head>

	<form id='formID' class='formular' method='post' action=''>
			 
			<legend>Inscription d'eleve</legend>
			<fieldset>
				<label>
					<span>* Nom : </span>
					<input class='validate[required,custom[noSpecialCaracters],length[0,100]]' name='nomE' id='nomE' type='text'>
				</label>
				<label>
					<span>* Prenom : </span>
					<input class='validate[required,custom[onlyLetter],length[0,100]] text-input' name='prenomE' id='prenomE' type='text'>
				</label>
			<label>
					<span>* Date de Naissance: (format YYYY-MM-DD)</span>
					<input class='validate[required,custom[date]] text-input' type='text' name='dateNaissE'  id='date' />
			</label>
				<label>
					<span>* Adresse : </span>
					<input class='validate[required,length[0,100]] text-input' name='adresseE' id='adresseE' type='text'>
				</label>
			<label>
					<span>* Ville : </span>
					<input class='validate[required,custom[onlyLetter],length[0,100]] text-input' name='villeE' id='villeE' type='text'>
			</label>
			<label>
					<span>* Code postal : </span>
					<input class='validate[required,custom[onlyNumber],length[0,5]] text-input' name='cpE' id='cpE' type='text'>
			</label>
			<label>
					<span>* Tel : </span>
					<input class='validate[required,custom[telephone]length[10,10]] text-input' name='telE' id='telE' type='text'>
			</label>


				<div>
					<span>Garcon: </span>
					<input class='validate[required] radio' name='GE'  value='1' id='GE' type='radio'>
					<span>Fille: </span>
					<input class='validate[required] radio' name='GE'  value='0' id='GEa' type='radio'>
				</div>


			<p><input class='submit' value='Valider' type='submit'></p>
		
				</fieldset>
		

			
</form>";

if(isset($_POST['nomE'])){
	require 'connect.php';

	$query = dbConnect()->prepare("INSERT INTO eleve (nomEleve, prenomEleve,dateNaissEleve, adresseEleve, cpEleve, telEleve, villeEleve, sexeEleve) VALUES (:nomE, :prenomE, :dateNaissE, :adresseE, :cpE, :telE, :villeE, :GE)");
	$query->bindParam(':nomE', $_POST['nomE']);
	$query->bindParam(':prenomE', $_POST['prenomE']);
	$query->bindParam(':dateNaissE', $_POST['dateNaissE']);
	$query->bindParam(':adresseE', $_POST['adresseE']);
	$query->bindParam(':cpE', $_POST['cpE']);
	$query->bindParam(':telE', $_POST['telE']);
	$query->bindParam(':villeE', $_POST['villeE']);
	$query->bindParam(':GE', $_POST['GE']);




	if($query->execute()){
		header("Location: Accueil.php");
	} else{
		echo 'ERROR';
	}
}

$site->affiche();

?>